/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.omazan.db.models;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author stryke
 */
@Entity
@Table(name = "ORDERS", catalog = "OMAZANDB", schema = "")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Orders.findAll", query = "SELECT o FROM Orders o"),
    @NamedQuery(name = "Orders.findByOrderId", query = "SELECT o FROM Orders o WHERE o.orderId = :orderId"),
    @NamedQuery(name = "Orders.findByTimeStamp", query = "SELECT o FROM Orders o WHERE o.timeStamp = :timeStamp")})
public class Orders implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "orderId", nullable = false)
    private Integer orderId;
    @Column(name = "timeStamp")
    @Temporal(TemporalType.TIMESTAMP)
    private Date timeStamp;
    @JoinColumn(name = "statusId", referencedColumnName = "statusId")
    @ManyToOne(fetch = FetchType.LAZY)
    private Deliverystatus statusId;
    @JoinColumn(name = "userId", referencedColumnName = "userId")
    @ManyToOne(fetch = FetchType.LAZY)
    private User userId;
    @OneToMany(mappedBy = "orderId", fetch = FetchType.LAZY)
    private Collection<Shipments> shipmentsCollection;
    @OneToMany(mappedBy = "orderId", fetch = FetchType.LAZY)
    private Collection<Orderdetails> orderdetailsCollection;

    public Orders() {
    }

    public Orders(Integer orderId) {
        this.orderId = orderId;
    }

    public Integer getOrderId() {
        return orderId;
    }

    public void setOrderId(Integer orderId) {
        this.orderId = orderId;
    }

    public Date getTimeStamp() {
        return timeStamp;
    }

    public void setTimeStamp(Date timeStamp) {
        this.timeStamp = timeStamp;
    }

    public Deliverystatus getStatusId() {
        return statusId;
    }

    public void setStatusId(Deliverystatus statusId) {
        this.statusId = statusId;
    }

    public User getUserId() {
        return userId;
    }

    public void setUserId(User userId) {
        this.userId = userId;
    }

    @XmlTransient
    public Collection<Shipments> getShipmentsCollection() {
        return shipmentsCollection;
    }

    public void setShipmentsCollection(Collection<Shipments> shipmentsCollection) {
        this.shipmentsCollection = shipmentsCollection;
    }

    @XmlTransient
    public Collection<Orderdetails> getOrderdetailsCollection() {
        return orderdetailsCollection;
    }

    public void setOrderdetailsCollection(Collection<Orderdetails> orderdetailsCollection) {
        this.orderdetailsCollection = orderdetailsCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (orderId != null ? orderId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Orders)) {
            return false;
        }
        Orders other = (Orders) object;
        if ((this.orderId == null && other.orderId != null) || (this.orderId != null && !this.orderId.equals(other.orderId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.omazan.entities.Orders[ orderId=" + orderId + " ]";
    }
    
}
